
$(document).ready(function(){


    $("#new-orgnizer-show").click(function(){
        $("#add-newOrgnizer").modal('show');
    });


    $("#add-orgnizer-save").click(function(){


            var postdata = {
                username: $("#add-orgnizer-username").val(),
                userpasswd:$("#add-orgnizer-userpasswd").val(),
                email:$("#add-orgnizer-email").val(),
                age:$("#add-orgnizer-userage").val(),
                sex:$("#add-orgnizer-usersex").val(),

                orgnizername: $("#add-orgnizer-orgnizername").val(),
                orgnizerinfo: $("#add-orgnizer-orgnizerinfo").val()
            };


        $.ajax({
            type:"GET",
            url:"/TestAdmin/Orgnizer/addOrgnizer",
            dataType:"json",
            async : false,
            data:postdata,
            success:function(data){

                if (data.code == 1){
                    alert(data.msg);
                    location.reload();
                }
                else{
                    alert("添加失败");
                }



            },error: function (jqXHR) {
                alert("添加组织发生错误failed"+jqXHR.status);
            }
        });
    });

    $(".delete-oid-btn").click(function(){
        $.ajax({
            type:"GET",
            url:"/TestAdmin/Orgnizer/deleteOrgnizer/oid/"+$(this).parent().parent().find('td').eq(0).html(),
            dataType:"json",
            async : false,

            success:function(data){

                if (data.code == 1){
                    alert(data.msg);
                    location.reload();
                }
                else{
                    alert("删除失败");
                }



            },error: function (jqXHR) {
                alert("删除组织发生错误failed"+jqXHR.status);
            }
        });
    });


    $(".setoid").click(function(){

        $.ajax({
        type:"GET",
        url:"/TestAdmin/Orgnizer/setOid/oid/"+$(this).parent().parent().find('td').eq(0).html(),
        dataType:"json",
        async : false,

        success:function(data){
            $("#ul-bar").find('li').eq(1).css("display", "block");
            $("#ul-bar").find('li').eq(2).css("display", "block");

            $("#ul-bar").find('li').eq(1).removeClass("active");
            $("#ul-bar").find('li').eq(0).removeClass("active");
            $("#ul-bar").find('li').eq(1).addClass("active");

            $("#userlist").removeClass("active in");
            $("#userlist").addClass("active in");
            $("#all-org").removeClass("active");

            //alert("请在左上角组织测评查看详细~");

            parent.location.href = "/TestAdmin/Orgnizer/index1";
            //$("#li-orgclass").trigger("click");
            //orgnizerUserData("/Admin");
            //orgnizerQuizStatus("/Admin");


        },error: function (jqXHR) {
            alert("failed"+jqXHR.status);
        }
    });
    });
});


